package com.perdragon.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.perdragon.entity.User;
import com.perdragon.repository.UserRepository;
import com.perdragon.service.UserService;

@Service
public class UserServiceImpl implements UserService {
	@Autowired
	private UserRepository userRepository;

	public List<User> listUser(int startRow) {
		return userRepository.listUser(startRow);
	}

	public int addUser(User user) {
		return userRepository.insert(user);
	}

	public void cancellation(int id) {
		userRepository.delete(id);
	}

	public int updateUser(User user) {
		return userRepository.update(user);
	}

	public List<User> getOneUser(int id) {
		return userRepository.selectById(id);
	}

	public int getRowNum() {
		return userRepository.getRowNum();
	}

	public User loginUser(String username, String password) {
		return userRepository.validateUser(username, password);
	}
}
